Periods in Javascript function definition (function window.onload(){}) [closed]

Posted by nemec on Stack Overflow See other posts from Stack Overflow or by nemec
Published on 2012-10-08T15:20:48Z Indexed on 2012/10/08 15:37 UTC
Read the original article Hit count: 95

Filed under:

Possible Duplicate:
JavaScript Function Syntax Explanation: function object.myFunction(){..}

I've seen some (legacy) javascript code recently that looks like:

function window.onload(){
  // some code
}

This doesn't look like valid javascript to me since you can't have a period in an identifier, but it seems to work in IE8. I assume it's the equivalent of:

window.onload = function(){}

I've tried the same code in Chrome and IE9 and both of them raise syntax exceptions, so am I correct in thinking that this "feature" of IE8 is some non-standard function definition that should be replaced? The code in question is only sent to IE browsers, so that's probably why I haven't run into this issue before.

© Stack Overflow or respective owner

Related posts about JavaScript